package com.edgar.plugin.entry

class ResourceEntry{

    private String resourceName
    private String resourceType
    private int resourceId
    private int newResourceId

    ResourceEntry(String resourceName, String resourceType, int resourceId){
        this.resourceName = resourceName
        this.resourceType = resourceType
        this.resourceId = resourceId
    }

    public void setNewResourceId(packageId, typeId, entryId) {
        newResourceId = packageId << 24 | typeId << 16 | entryId
    }

    /**
     * @return the hexadecimal resource id
     */
    public String getHexResourceId() {
        return "0x${Integer.toHexString(resourceId)}"
    }

    /**
     * @return the hexadecimal new resource id
     */
    public String getHexNewResourceId() {
        return "0x${Integer.toHexString(newResourceId)}"
    }

    public String getName() {
        return resourceName
    }

    public String getType() {
        return resourceType
    }

    boolean equals(o) {
        if (this.is(o)) return true
        if (getClass() != o.class) return false

        ResourceEntry that = (ResourceEntry) o

        if (resourceName != that.resourceName) return false
        if (resourceType != that.resourceType) return false

        return true
    }


    int hashCode() {
        int result
        result = resourceType.hashCode()
        result = 31 * result + resourceName.hashCode()
        return result
    }
}